<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="TStaff" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<alias>
    <typeAlias alias="TStaff" type="EIA.Basic.Model.TStaff, EIA.Basic.Model" />
</alias>

<resultMaps>
<resultMap id="select-tstaff-result" class="TStaff">
<constructor>
    <argument argumentName="stf_id" column="stf_id"/>
    <argument argumentName="stf_name" column="stf_name"/>
    <argument argumentName="dep_id" column="dep_id"/>
    <argument argumentName="dep_name" column="dep_name"/>
    <argument argumentName="contact_tel" column="contact_tel"/>
    <argument argumentName="pos_id" column="pos_id"/>
    <argument argumentName="pos_level" column="pos_level"/>
    <argument argumentName="pos_name" column="pos_name"/>
    <argument argumentName="is_active" column="is_active"/>
</constructor>
<!--
    <result property="StfId" column="stf_id"/>
    <result property="StfName" column="stf_name"/>
    <result property="DepId" column="dep_id"/>
    <result property="DepName" column="dep_name"/>
    <result property="ContactTel" column="contact_tel"/>
    <result property="PosId" column="pos_id"/>
    <result property="PosLevel" column="pos_level"/>
    <result property="PosName" column="pos_name"/>
    <result property="IsActive" column="is_active"/>
-->
</resultMap>
</resultMaps>

<statements>
<sql id="sql_TStaff_where_pk">
WHERE stf_id=#StfId#
</sql>

<sql id="sql_TStaff_where_cv">
<dynamic prepend="WHERE">
    <isPropertyAvailable property="StfId" prepend="AND">stf_id=#StfId#</isPropertyAvailable>
    <isPropertyAvailable property="StfName" prepend="AND">stf_name LIKE concat('%', #StfName#, '%')</isPropertyAvailable>
    <isPropertyAvailable property="DepId" prepend="AND">dep_id=#DepId#</isPropertyAvailable>
    <isPropertyAvailable property="DepName" prepend="AND">dep_name LIKE concat('%', #DepName#, '%')</isPropertyAvailable>
    <isPropertyAvailable property="ContactTel" prepend="AND">contact_tel LIKE concat('%', #ContactTel#, '%')</isPropertyAvailable>
    <isPropertyAvailable property="PosId" prepend="AND">pos_id=#PosId#</isPropertyAvailable>
    <isPropertyAvailable property="PosLevel" prepend="AND">pos_level=#PosLevel#</isPropertyAvailable>
    <isPropertyAvailable property="PosName" prepend="AND">pos_name LIKE concat('%', #PosName#, '%')</isPropertyAvailable>
    <isPropertyAvailable property="IsActive" prepend="AND">is_active=#IsActive#</isPropertyAvailable>
</dynamic>
</sql>

<sql id="sql_TStaff_set_cols">
<dynamic prepend="SET">
    <isPropertyAvailable property="StfName" prepend=",">stf_name=#StfName#</isPropertyAvailable>
    <isPropertyAvailable property="DepId" prepend=",">dep_id=#DepId#</isPropertyAvailable>
    <isPropertyAvailable property="DepName" prepend=",">dep_name=#DepName#</isPropertyAvailable>
    <isPropertyAvailable property="ContactTel" prepend=",">contact_tel=#ContactTel#</isPropertyAvailable>
    <isPropertyAvailable property="PosId" prepend=",">pos_id=#PosId#</isPropertyAvailable>
    <isPropertyAvailable property="PosLevel" prepend=",">pos_level=#PosLevel#</isPropertyAvailable>
    <isPropertyAvailable property="PosName" prepend=",">pos_name=#PosName#</isPropertyAvailable>
    <isPropertyAvailable property="IsActive" prepend=",">is_active=#IsActive#</isPropertyAvailable>
</dynamic>
</sql>

<select id="SelectTStaff" parameterClass="" resultMap="TStaff.select-tstaff-result">
SELECT *
FROM t_staff
<include refid="sql_TStaff_where_pk"/><!--where-->
</select>

<select id="SelectTStaff_CV" parameterClass="System.Collections.IDictionary" resultMap="TStaff.select-tstaff-result">
SELECT *
FROM t_staff
<include refid="sql_TStaff_where_cv"/><!--where-->
</select>

<insert id="InsertTStaff" parameterClass="TStaff">
<!--pre selectKey place-->
INSERT INTO t_staff(
<dynamic prepend=" ">
    <isPropertyAvailable property="StfName" prepend=",">stf_name</isPropertyAvailable>
    <isPropertyAvailable property="DepId" prepend=",">dep_id</isPropertyAvailable>
    <isPropertyAvailable property="DepName" prepend=",">dep_name</isPropertyAvailable>
    <isPropertyAvailable property="ContactTel" prepend=",">contact_tel</isPropertyAvailable>
    <isPropertyAvailable property="PosId" prepend=",">pos_id</isPropertyAvailable>
    <isPropertyAvailable property="PosLevel" prepend=",">pos_level</isPropertyAvailable>
    <isPropertyAvailable property="PosName" prepend=",">pos_name</isPropertyAvailable>
    <isPropertyAvailable property="IsActive" prepend=",">is_active</isPropertyAvailable>
</dynamic>
)VALUES(
<dynamic prepend=" ">
    <isPropertyAvailable property="StfName" prepend=",">#StfName#</isPropertyAvailable>
    <isPropertyAvailable property="DepId" prepend=",">#DepId#</isPropertyAvailable>
    <isPropertyAvailable property="DepName" prepend=",">#DepName#</isPropertyAvailable>
    <isPropertyAvailable property="ContactTel" prepend=",">#ContactTel#</isPropertyAvailable>
    <isPropertyAvailable property="PosId" prepend=",">#PosId#</isPropertyAvailable>
    <isPropertyAvailable property="PosLevel" prepend=",">#PosLevel#</isPropertyAvailable>
    <isPropertyAvailable property="PosName" prepend=",">#PosName#</isPropertyAvailable>
    <isPropertyAvailable property="IsActive" prepend=",">#IsActive#</isPropertyAvailable>
</dynamic>
)
<selectKey resultClass="int" type="post" property="StfId" >
SELECT LAST_INSERT_ID()
</selectKey>
</insert>

<update id="UpdateTStaff" parameterClass="System.Collections.IDictionary">
UPDATE t_staff
<include refid="sql_TStaff_set_cols"/><!--set-->
<include refid="sql_TStaff_where_pk"/><!--where-->
</update>

<delete id="DeleteTStaff" parameterClass="">
DELETE FROM t_staff
<include refid="sql_TStaff_where_pk"/><!--where-->
</delete>

<statement id="DeleteTStaff_CV" parameterClass="TStaff">
DELETE FROM t_staff
<include refid="sql_TStaff_where_cv"/><!--where-->
</statement>

<delete id="ClearTStaff">
DELETE FROM t_staff
</delete>
</statements>
</sqlMap>